build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v5
- name: Install libcleri
run: |
git clone https://github.com/cesbit/libcleri.git
- name: Install dependencies
run: |
sudo apt-get update -y
- sudo apt-get install -y libuv1-dev libpcre2-dev libyajl-dev valgrind
+ sudo apt-get install -y uuid-dev libuv1-dev libpcre2-dev libyajl-dev valgrind
- name: Run tests
run: |
cd ./Release/
+siridb-server (2.0.53-0~cb1) unstable; urgency=medium
+
+ * New upstream release
+ - Fixed bug with rollback after failed HTTP request for a new database
+ - Use heap instead of stack for translating a forward query
+ - Fixed reaclloc with zero bug
+ - Update testing files
+
+ -- Jeroen van der Heijden <jeroen@cesbit.com> Wed, 22 Oct 2025 10:04:00 +0200
+
siridb-server (2.0.52-0~cb1) unstable; urgency=medium
* New upstream release
-FROM amd64/alpine:3.13
+FROM amd64/alpine
RUN apk update && \
apk upgrade && \
apk add gcc make libuv-dev musl-dev pcre2-dev yajl-dev util-linux-dev linux-headers git && \
make clean && \
make
-FROM amd64/alpine:3.12.4
+FROM amd64/alpine
RUN apk update && \
apk add pcre2 libuv libuuid yajl && \
mkdir -p /etc/siridb && \
#define SIRIDB_VERSION_MAJOR 2
#define SIRIDB_VERSION_MINOR 0
-#define SIRIDB_VERSION_PATCH 52
+#define SIRIDB_VERSION_PATCH 53
/*
* Use SIRIDB_VERSION_PRE_RELEASE for alpha release versions.
-FROM ubuntu:18.04 AS builder
+FROM ubuntu:24.04 AS builder
RUN apt-get update && \
apt-get install -y \
libcleri-dev \
COPY ./Release/ ./Release/
RUN cd ./Release && \
make clean && \
- CFLAGS="-Werror -std=gnu89" make
+ CFLAGS="-Werror -std=gnu89" make all
-FROM python
+FROM python:3.12
RUN apt-get update && \
apt-get install -y \
valgrind \
args = parser.parse_args()
- loop = asyncio.get_event_loop()
+ loop = asyncio.new_event_loop()
loop.run_until_complete(print_google_finance_data(
ticker=args.ticker,
interval=args.interval,
#!/usr/bin/python3
-import os
import sys
import argparse
import asyncio
import time
import logging
-import string
import random
import datetime
import math
}[self.kind]
self.lts = self._timestamp
- factor = 10**r.randint(int(self.kind == int), 9)
+ factor = 10**r.randint(int(self.kind is int), 9)
self.random_range = (
int(r.random() * -factor),
int(r.random() * factor) + 1)
self.likely_equal = r.choice([0.01, 0.1, 0.2, 0.5, 0.99])
self.likely_change_sign = r.choice([0.0, 0.1, 0.25, 0.5, 0.9])
- self.as_int = wrong_type and self.kind == float and r.random() > 0.9
+ self.as_int = wrong_type and self.kind is float and r.random() > 0.9
self.likely_inf = r.random() * 0.2 \
- if self.kind == float and r.random() > 0.95 else False
+ if self.kind is float and r.random() > 0.95 else False
self.likely_nan = r.random() * 0.2 \
- if self.kind == float and r.random() > 0.95 else False
+ if self.kind is float and r.random() > 0.95 else False
- self.gen_float = wrong_type and self.kind == int and r.random() > 0.97
+ self.gen_float = wrong_type and self.kind is int and r.random() > 0.97
self.name = self._gen_name()
Series._series.append(self)
[s.strip() for s in server.split(':')]
for server in args.servers.split(',')])
- loop = asyncio.get_event_loop()
+ loop = asyncio.new_event_loop()
loop.run_until_complete(dump_data(siri, args))
total_time = time.time() - start_time
parser.add_argument("-p", "--port", type=int, default=9104)
args = parser.parse_args()
- loop = asyncio.get_event_loop()
+ loop = asyncio.new_event_loop()
loop.run_until_complete(main(args))
title = 'Test compression'
GEN_POINTS = functools.partial(
- gen_points, n=100, time_precision=TIME_PRECISION)
+ gen_points, time_precision=TIME_PRECISION)
async def _test_series(self, client):
await self.client0.query('count groups where series > 2'),
{'groups': 2})
+ self.assertEqual(
+ await self.client0.query('select * from * before now'),
+ DATA)
+
self.client0.close()
self.client1.close()
await self.client0.connect()
x = requests.get(
- f'http://localhost:9020/get-version', auth=('sa', 'siri'))
+ 'http://localhost:9020/get-version', auth=('sa', 'siri'))
self.assertEqual(x.status_code, 200)
v = x.json()
self.assertTrue(isinstance(v[0], str))
x = requests.post(
- f'http://localhost:9020/insert/dbtest',
+ 'http://localhost:9020/insert/dbtest',
auth=('iris', 'siri'),
headers={'Content-Type': 'application/json'})
}
x = requests.post(
- f'http://localhost:9020/insert/dbtest',
+ 'http://localhost:9020/insert/dbtest',
data=json.dumps(data),
auth=('iris', 'siri'),
headers={'Content-Type': 'application/json'}
}
x = requests.post(
- f'http://localhost:9021/new-pool',
+ 'http://localhost:9021/new-pool',
data=json.dumps(data),
auth=('sa', 'siri'),
headers={'Content-Type': 'application/json'})
data = {'data': [[1579521271, 10], [1579521573, 20]]}
x = requests.post(
- f'http://localhost:9020/insert/dbtest',
+ 'http://localhost:9020/insert/dbtest',
json=data,
auth=('iris', 'siri'))
'success_msg': 'Successfully inserted 2 point(s).'})
x = requests.post(
- f'http://localhost:9020/query/dbtest',
+ 'http://localhost:9020/query/dbtest',
json={'q': 'select * from "data"'},
auth=('iris', 'siri'))
self.assertEqual(x.json(), data)
x = requests.post(
- f'http://localhost:9020/query/dbtest',
+ 'http://localhost:9020/query/dbtest',
json={'q': 'select * from "data"', 't': 'ms'},
auth=('iris', 'siri'))
self.assertEqual(x.json(), data)
x = requests.post(
- f'http://localhost:9020/query/dbtest',
+ 'http://localhost:9020/query/dbtest',
data=qpack.packb({
'q': 'select sum(1579600000) from "data"',
't': 'ms'}),
{'data': [[1579600000000, 30]]})
x = requests.post(
- f'http://localhost:9021/new-account',
+ 'http://localhost:9021/new-account',
json={'account': 't', 'password': ''},
auth=('sa', 'siri'))
'service account name should have at least 2 characters'})
x = requests.post(
- f'http://localhost:9021/new-account',
+ 'http://localhost:9021/new-account',
json={'account': 'tt', 'password': 'pass'},
auth=('sa', 'siri'))
auth = ('tt', 'pass')
x = requests.post(
- f'http://localhost:9021/new-replica', json=data, auth=auth)
+ 'http://localhost:9021/new-replica', json=data, auth=auth)
self.assertEqual(x.status_code, 400)
self.assertEqual(x.json(), {
'error_msg': "database name already exists: 'dbtest'"})
x = requests.post(
- f'http://localhost:9022/new-replica', json=data, auth=auth)
+ 'http://localhost:9022/new-replica', json=data, auth=auth)
self.assertEqual(x.status_code, 401)
auth = ('sa', 'siri')
x = requests.post(
- f'http://localhost:9022/new-replica', json=data, auth=auth)
+ 'http://localhost:9022/new-replica', json=data, auth=auth)
self.assertEqual(x.status_code, 400)
self.assertEqual(x.json(), {
data['port'] = 9000
x = requests.post(
- f'http://localhost:9022/new-replica', json=data, auth=auth)
+ 'http://localhost:9022/new-replica', json=data, auth=auth)
self.assertEqual(x.status_code, 200)
self.assertEqual(x.json(), 'OK')
await self.assertIsRunning(self.db, self.client0, timeout=50)
x = requests.get(
- f'http://localhost:9022/get-databases', auth=auth)
+ 'http://localhost:9022/get-databases', auth=auth)
self.assertEqual(x.status_code, 200)
self.assertEqual(x.json(), ['dbtest'])
def run_test(test, loglevel='CRITICAL'):
assert isinstance(test, TestBase)
- loop = asyncio.get_event_loop()
+ loop = asyncio.new_event_loop()
cleanup()
loop.run_until_complete(_run_test(test, loglevel))
' -H' if self.HOLD_TERM else ''),
shell=True)
elif self.TERMINAL == 'xterm':
- self.proc = subprocess.Popen(
- 'xterm {}-title {} -geometry {} -e "{}{} --config {}"'
- .format('-hold ' if self.HOLD_TERM else '',
- self.name,
- self.GEOMETRY,
- VALGRIND if self.MEM_CHECK else '',
- SIRIDBC.format(BUILDTYPE=self.BUILDTYPE),
- self.cfgfile),
- shell=True)
+ self.proc = subprocess.Popen((
+ 'xterm {}-title {} -geometry {} -e "{}{} --config {} '
+ '--log-colorized"'
+ ).format('-hold ' if self.HOLD_TERM else '',
+ self.name,
+ self.GEOMETRY,
+ VALGRIND if self.MEM_CHECK else '',
+ SIRIDBC.format(BUILDTYPE=self.BUILDTYPE),
+ self.cfgfile),
+ shell=True)
elif self.TERMINAL is None:
errfn = f'testdir/{self.test_title}-{self.name}-err.log'
outfn = f'testdir/{self.test_title}-{self.name}-out.log'
uint8_t diff = node->offset - pos;
uint8_t oldn = node->n;
node->n += diff;
- tmp = (ct_nodes_t *) realloc(
- node->nodes,
- node->n * sizeof(ct_nodes_t));
- if (tmp == NULL && node->n)
+ if (node->n == 0)
{
- node->n -= diff;
- rc = -1;
+ free(node->nodes);
+ node->nodes = NULL;
+ node->offset = pos;
}
else
{
- node->nodes = tmp;
- node->offset = pos;
- memmove(node->nodes + diff,
+ tmp = (ct_nodes_t *) realloc(
node->nodes,
- oldn * sizeof(ct_nodes_t));
- memset(node->nodes, 0, diff * sizeof(ct_nodes_t));
+ node->n * sizeof(ct_nodes_t));
+ if (tmp == NULL)
+ {
+ node->n -= diff;
+ rc = -1;
+ }
+ else
+ {
+ node->nodes = tmp;
+ node->offset = pos;
+ memmove(node->nodes + diff,
+ node->nodes,
+ oldn * sizeof(ct_nodes_t));
+ memset(node->nodes, 0, diff * sizeof(ct_nodes_t));
+ }
}
}
else if (pos >= node->offset + node->n)
if (source->len > points->len)
{
- dpt = (siridb_point_t *) realloc(
- points->data,
- points->len * sizeof(siridb_point_t));
- if (dpt == NULL && points->len)
+ if (points->len == 0)
{
- /* not critical */
- log_error("Error while re-allocating memory for points");
+ free(points->data);
+ points->data = NULL;
}
else
{
- points->data = dpt;
+ dpt = (siridb_point_t *) realloc(
+ points->data,
+ points->len * sizeof(siridb_point_t));
+ if (dpt == NULL)
+ {
+ /* not critical */
+ log_error("Error while re-allocating memory for points");
+ }
+ else
+ {
+ points->data = dpt;
+ }
}
}
}
if (points->len < max_sz)
{
/* shrink points allocation */
- point = realloc(points->data, points->len * sizeof(siridb_point_t));
- if (point == NULL && points->len)
+ if (points->len == 0)
{
- /* not critical */
- log_error("Re-allocation points failed.");
+ free(points->data);
+ points->data = NULL;
}
else
{
- points->data = point;
+ point = realloc(points->data, points->len * sizeof(siridb_point_t));
+ if (point == NULL)
+ {
+ /* not critical */
+ log_error("Re-allocation points failed.");
+ }
+ else
+ {
+ points->data = point;
+ }
}
}
/* else { assert (points->len == max_sz); } */
*/
int siridb_points_resize(siridb_points_t * points, size_t n)
{
+ siridb_point_t * tmp;
assert( points->len <= n );
- siridb_point_t * tmp = realloc(points->data, sizeof(siridb_point_t) * n);
- if (tmp == NULL && n)
+ if (n == 0)
+ {
+ free(points->data);
+ points->data = NULL;
+ return 0;
+ }
+
+ tmp = realloc(points->data, sizeof(siridb_point_t) * n);
+ if (tmp == NULL)
{
return -1;
}
#define QUERY_TOO_LONG -1
-#define QUERY_MAX_LENGTH 8192
#define QUERY_EXTRA_ALLOC_SIZE 200
#define SIRIDB_FWD_SERVERS_TIMEOUT 5000 /* 5 seconds */
if (query->flags & SIRIDB_QUERY_FLAG_REBUILD)
{
/* reserve 200 extra chars */
- char buffer[packer->alloc_size];
+ char * buffer = malloc(packer->alloc_size);
size_t size = packer->alloc_size;
siridb_t * siridb = query->siridb;
- rc = QUERY_rebuild(
+ rc = (buffer == NULL) ? -1 : QUERY_rebuild(
siridb,
cleri_gn(query->pr->tree->children),
buffer,
(const unsigned char *) buffer,
packer->alloc_size - size);
}
+ free(buffer);
}
else
{
else
{
series->idx_len -= offset;
- idx = (idx_t *) realloc(
- series->idx,
- series->idx_len * sizeof(idx_t));
- if (idx == NULL && series->idx_len)
+ if (series->idx_len == 0)
{
- log_error("Re-allocation failed while removing series from "
- "shard index");
+ free(series->idx);
+ series->idx = NULL;
}
else
{
- series->idx = idx;
+ idx = (idx_t *) realloc(
+ series->idx,
+ series->idx_len * sizeof(idx_t));
+ if (idx == NULL)
+ {
+ log_error(
+ "Re-allocation failed while removing series from "
+ "shard index");
+ }
+ else
+ {
+ series->idx = idx;
+ }
}
if (series->start >= start && series->start < end)
{
}
/* shrink memory to the new size */
- idx = (idx_t *) realloc(
- series->idx,
- series->idx_len * sizeof(idx_t));
- if (idx == NULL && series->idx_len)
+ if (series->idx_len == 0)
{
- /* this is not critical since the original allocated block still
- * works.
- */
- log_error("Shrinking memory for one series has failed!");
+ free(series->idx);
+ series->idx = NULL;
}
else
{
- series->idx = idx;
+ idx = (idx_t *) realloc(
+ series->idx,
+ series->idx_len * sizeof(idx_t));
+ if (idx == NULL)
+ {
+ /* this is not critical since the original allocated block still
+ * works.
+ */
+ log_error("Shrinking memory for one series has failed!");
+ }
+ else
+ {
+ series->idx = idx;
+ }
}
}
else
...)
{
char err_msg[SIRI_MAX_SIZE_ERR_MSG];
-
va_list args;
va_start(args, fmt);
vsnprintf(err_msg, SIRI_MAX_SIZE_ERR_MSG, fmt, args);
va_end(args);
-
sirinet_pkg_t * package = sirinet_pkg_err(
adm_client->pid,
strlen(err_msg),
}
sirinet_stream_decref(siri.client);
-
uv_close((uv_handle_t *) &siri.timer, NULL);
}
void siri_service_request_rollback(const char * dbpath)
{
size_t dbpath_len = strlen(dbpath);
- char dbfn[dbpath_len + max_filename_sz];
-
+ char * dbfn = malloc(dbpath_len + max_filename_sz + 1);
+ if (dbfn == NULL)
+ {
+ log_error("Roll-back creating new database has failed.");
+ return;
+ }
sprintf(dbfn, "%s%s", dbpath, DB_CONF_FN);
unlink(dbfn);
sprintf(dbfn, "%s%s", dbpath, DB_DAT_FN);
unlink(dbfn);
sprintf(dbfn, "%s%s", dbpath, REINDEX_FN);
unlink(dbfn);
+ free(dbfn);
if (rmdir(dbpath))
{
log_error("Roll-back creating new database has failed.");